package view
{
	import com.greensock.TweenLite;
	
	import data.Globals;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.utils.setTimeout;

	/**
	 *@author CrazyChen
	 *2013-6-5
	 *public class TipsView extends BaseView
	 *import view.base.BaseView;
	 */
	public class TipsView extends Sprite
	{
		private var movieclip:MovieClip;
		private var txt:TextField;
		public function TipsView()
		{
			super();
			movieclip = new Tip();
			movieclip.x = Globals.stage_width/2;
			movieclip.y = Globals.stage_height/2;
			txt = movieclip.content;
			this.addChild(movieclip);
			this.mouseChildren = false;
			this.mouseEnabled = false;
		}
		
		public function show(str:String):void{
			(Globals.gameView as Sprite).addChild(this);
			txt.text = str;
			movieclip.alpha = 0;
			TweenLite.to(movieclip,1,{alpha:1});
			setTimeout(hide,4000);
		}
		
		public function hide():void{
			TweenLite.to(movieclip,1,{alpha:0,onComplete:remove});
		}
		
		private function remove():void{
			if(this.parent)this.parent.removeChild(this);
		}
	}
}